package junittests;

import static org.junit.Assert.*;

import java.math.BigInteger;

import org.junit.Before;
import org.junit.Test;

import domains.Interval;
import domains.IntervalBound;


public class IntervalTest {
	IntervalBound minusInf;
	IntervalBound plusInf;
	IntervalBound zero;
	IntervalBound one;
	IntervalBound two;
	IntervalBound five;
	IntervalBound minusOne;
	IntervalBound minusTwo;
	IntervalBound minusFive;
	IntervalBound three;
	IntervalBound minusThree;
	IntervalBound four;
	IntervalBound minusFour;
	IntervalBound six;
	IntervalBound minusSix;
	IntervalBound eight;
	IntervalBound minusEight;
	
	Interval minusInf_plusInf;
	Interval minusInf_zero;
	Interval zero_one;
	Interval one_five;
	Interval minusTwo_zero;
	Interval minusFive_minusOne;
	Interval minusOne_two;
	Interval zero_zero;
	Interval one_one;
	Interval minusFive_minusFive;

	@Before
	public void setUp(){
		minusInf = new IntervalBound(null,true,false);
		plusInf = new IntervalBound(null,false,true);
		zero = new IntervalBound(BigInteger.ZERO,false,false);
		one = new IntervalBound(BigInteger.ONE,false,false);
		two = new IntervalBound(BigInteger.valueOf(2),false,false);
		five = new IntervalBound(BigInteger.valueOf(5),false,false);
		minusOne = new IntervalBound(BigInteger.valueOf(-1),false,false);
		minusTwo = new IntervalBound(BigInteger.valueOf(-2),false,false);
		minusFive = new IntervalBound(BigInteger.valueOf(-5),false,false);
		three = new IntervalBound(BigInteger.valueOf(3),false,false);
		minusThree = new IntervalBound(BigInteger.valueOf(-3),false,false);
		four = new IntervalBound(BigInteger.valueOf(4),false,false);
		minusFour = new IntervalBound(BigInteger.valueOf(-4),false,false);
		six = new IntervalBound(BigInteger.valueOf(6),false,false);
		minusSix = new IntervalBound(BigInteger.valueOf(-6),false,false);
		eight = new IntervalBound(BigInteger.valueOf(8),false,false);
		minusEight = new IntervalBound(BigInteger.valueOf(-8),false,false);
		
		minusInf_plusInf = new Interval(minusInf,plusInf);
		minusInf_zero = new Interval(minusInf,zero);
		zero_one = new Interval(zero,one);
		minusTwo_zero = new Interval(minusTwo,zero);
		minusFive_minusOne = new Interval(minusFive,minusOne);
		minusOne_two = new Interval(minusOne,two);
		one_five = new Interval(one,five);
		zero_zero = new Interval(zero,zero);
		one_one = new Interval(one,one);
		minusFive_minusFive = new Interval(minusFive,minusFive);
	}
	
	@Test
	public void testEquals(){
		assertTrue("equals ([-inf,inf],[-inf,inf])",minusInf_plusInf.equals(minusInf_plusInf));
		assertTrue("equals ([-inf,0],[-inf,0])",minusInf_zero.equals(minusInf_zero));
		assertTrue("equals ([-1,2],[-1,2])",minusOne_two.equals(minusOne_two));
		assertTrue("equals ([1,5],[1,5])",one_five.equals(one_five));
		assertFalse("equals ([-2,0],[0,1])",minusTwo_zero.equals(zero_one));
	}
	
	@Test
	public void testJoin(){
		assertTrue(false);
	}
	
	@Test
	public void testMeet(){
		assertTrue(false);
	}
	
	@Test
	public void testWidening(){
		assertTrue(false);
	}
	
	@Test
	public void testNarrowing(){
		assertTrue(false);
	}
	
	@Test
	public void testNegate(){
		assertEquals("neg [-inf,inf]",minusInf_plusInf,minusInf_plusInf.negate());
		assertEquals("neg [-inf,0]",new Interval(zero,plusInf),minusInf_zero.negate());
		assertEquals("neg [0,0]",zero_zero,zero_zero.negate());
		assertEquals("neg [1,5]",new Interval(minusFive,minusOne),one_five.negate());
		assertEquals("neg [-1,2]",new Interval(minusTwo,one),minusOne_two.negate());
		assertEquals("neg [-5,-1]",new Interval(one,five),minusFive_minusOne.negate());
	}
	
	@Test
	public void testAdd(){
		IntervalBound ten = new IntervalBound(BigInteger.valueOf(10),false,false);
		
		assertEquals("add ([-inf,inf],[-inf,inf])",minusInf_plusInf,minusInf_plusInf.add(minusInf_plusInf));
		assertEquals("add ([-inf,inf],[0,0]",minusInf_plusInf,minusInf_plusInf.add(zero_zero));
		assertEquals("add ([-inf,inf],[1,5]",minusInf_plusInf,minusInf_plusInf.add(one_five));
		assertEquals("add ([1,5],[-5,-1]])",new Interval(minusFour,four),one_five.add(minusFive_minusOne));
		assertEquals("add ([1,5],[1,5])",new Interval(two,ten),one_five.add(one_five));
		assertEquals("add ([-1,2],[-2,0])",new Interval(minusThree,two),minusOne_two.add(minusTwo_zero));
	}
	
	@Test
	public void testSub(){
		assertEquals("sub ([-inf,inf],[-inf,inf])",minusInf_plusInf,minusInf_plusInf.subtract(minusInf_plusInf));
		assertEquals("sub ([-inf,inf],[0,0])",minusInf_plusInf,minusInf_plusInf.subtract(zero_zero));
		assertEquals("sub ([-inf,inf],[1,5])",minusInf_plusInf,minusInf_plusInf.subtract(one_five));
		assertEquals("sub ([-inf,0],[1,5])",new Interval(minusInf,minusOne),minusInf_zero.subtract(one_five));
		assertEquals("sub ([1,5],[-inf,0])",new Interval(one,plusInf),one_five.subtract(minusInf_zero));
		
		//assertTrue(false);
	}
	
	@Test
	public void testMul(){
		assertTrue(false);
	}
	
	@Test
	public void testDiv(){
		assertTrue(false);
	}
	
	@Test
	public void testEq(){
		assertTrue(false);
	}
	
	@Test
	public void testNe(){
		assertTrue(false);
	}
	
	@Test
	public void testLt(){
		assertTrue(false);
	}
	
	@Test
	public void testGe(){
		assertTrue(false);
	}
	
	@Test
	public void testLe(){
		assertTrue(false);
	}
	
	@Test
	public void testGt(){
		assertTrue(false);
	}

}
